package cn.wuweixiang.springbootdemo.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * DemoInterceptor
 *
 * @author weixiang.wu
 * @date 2018-08-22 20:53
 **/
public class DemoInterceptor implements HandlerInterceptor {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		System.err.println("DemoInterceptor.preHandle(Controller方法调用之前)");
		System.err.println("DemoInterceptor.preHandle只有返回true才会继续向下执行，返回false取消当前请求");
		System.err.println("DemoInterceptor.preHandle当前返回true");
		return true;
	}

	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		System.err.println("DemoInterceptor.postHandle");
	}

	@Override
	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
		System.err.println("DemoInterceptor.afterCompletion");
	}
}
